package acwin;

import java.util.Scanner;

public class EX795 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            if(i==0){
                nums[i] = scanner.nextInt();
            }else{
                nums[i] = nums[i-1]+ scanner.nextInt();
            }
        }

        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(nums[b]-nums[a-1]);
        }
    }
}
